<template>
    <div class="big-box">
        <div class="header">
            <img src="../../../../../assets/bigScreen/header2.png" alt="" />
            <div class="backBox" @click="goBack"></div>
        </div>
        <div class="backToBox">
            <div class="backTo" @click="gotoHome">
                <div>返回总窗口</div>
            </div>
            <div class="backTo" @click="backToOne">
                <div>返回上一页</div>
            </div>
        </div>
        <div class="centerBox">
            <div class="sreenTitle">众创空间</div>
            <div class="center">
                <div class="incubation_search">
                    <div class="typeContent">
                        <!-- v-if="tabvalue!='1'" -->
                        <div class="filter-container">
                            <div class="filter-type" v-for="(item, index) in typeList" :key="index"
                                :style="{ height: item.showMore ? 'initial' : '55px' }">
                                <div class="filter-type-title">{{ item.title }}：</div>
                                <div style="width: 110rem;">
                                    <div :class="['filter-item', typeIds[index] == null ? 'active' : '']" @click="setType(index, null)">
                                        全部
                                    </div>
                                    <div v-for="sItem in item.list" :class="['filter-item', typeIds[index] == sItem.id ? 'active' : '']"
                                        :key="sItem.id" @click="setType(index, sItem)">
                                        {{ sItem.name }}
                                    </div>
                                    <div class="filter-more-btn" @click="item.showMore = !item.showMore">
                                        <span>更多分类</span>
                                        <img :style="{ transform: item.showMore ? 'scaleY(-1)' : 'scaleY(1)' }" src="../../../../../assets/down.png"
                                            alt="" />
                                    </div>
                                </div>
                            </div>
                            <div class="filter-type" :style="{ height: arearShowMore ? 'initial' : '55px' }">
                                <div class="filter-type-title">城市：</div>
                                <div style="width: 110rem;">
                                    <div :class="areaIndex == index ? 'filter-item active' : 'filter-item'"
                                        v-for="(item, index) in areadata[0].children" @click="areaIndex = index; getOrg()" :key="index">
                                        <span v-if="item.name=='市直属'">{{areadata[0].name}}</span>
                                        <span v-else>{{item.name}}</span>
                                    </div>
                                    <div :class="areaIndex == -1 ? 'filter-item active' : 'filter-item'" @click="areaIndex = -1; getOrg()">
                                        <span>其他</span>
                                    </div>
                                    <div class="filter-more-btn" @click="arearShowMore = !arearShowMore">
                                        <span>更多分类</span>
                                        <img :style="{ transform: arearShowMore ? 'scaleY(-1)' : 'scaleY(1)' }" src="../../../../../assets/down.png"
                                            alt="" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="typeContent searchListBox" v-if="dataList.length">
                        <div class="sitem" v-for="(item, index) in dataList" :key="index">
                            <!-- {{item}} -->
                            <div class="sleft">
                                <img alt="暂无图片"
                                    :src="item.imgUrl ? item.imgUrl[0]=='/'? baseURL+item.imgUrl:item.imgUrl: '/headerImg/login-bg.png'" />
                                <div class="textBox">
                                    <div style="display: flex;align-items: center;">
                                        <span class="title">{{ item.name }}</span>
                                        <!-- <div class="type">未评定</div> -->
                                    </div>
                                    <!-- <div class="subtext">所属领域：综合 孵化  面积：{{item.acreage}}（平方米）</div> -->
                                    <div class="subtext" v-if="tabvalue != '1'">
                                        电话：{{ item.mobile || '--' }} 面积：{{ item.acreage || '--' }}（平方米）
                                    </div>
                                    <!-- <div class="subtext">公司：华讯高科股份有限公司</div> -->
                                    <div class="subtext" v-if="tabvalue != '1'">{{ item.city }}{{ item.address }}</div>
                                    <div class="subtext" v-else>所在盟市：{{ item.city }}</div>
                                </div>
                            </div>
                            <!-- v-if="tabvalue!='1'" -->
                            <div class="sright" @click="toDetail(item.id)">查看详情</div>
                        </div>
                        <div style="text-align: center;padding: 5rem 0;">
                            <a-pagination v-model:current="pages.number" v-model:pageSize="pages.size" :total="total" :showSizeChanger='false'
                                @change="pageChange" />
                        </div>
                    </div>

                    <noData v-else />
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref, onMounted, reactive } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { innovationList, industryOne } from '../../../../../api/incubation'
import { getarea } from '../../../../../api/home'
import noData from '../../../no-data.vue'
import axios from "axios";
const router = useRouter()
const pageAct = ref(1)
const dates = ref('')
const route = useRoute()
//判断时间是否为个位数，如果时间为个位数就在时间之前补上一个“0”
const check = (val) => {
    if (val < 10) {
        return '0' + val
    } else {
        return val
    }
}

const gotoScreen = (act) => {
    router.push({
        path: '/bigScreen',
        query: {
            act: act,
        },
    })
}
const gotoHome = (act) => {
    router.push({
        path: '/bigScreenIndex',
    })
}
const backToOne = (act) => {
    router.go(-1)
}

// gotoHome() {
//             this.$router.push({
//                 path: '/bigScreenIndex',
//             })
//         },
//         backToOne() {
//             console.log('11');
//             this.$router.go(-1)
//         },

const displayTime = () => {
    //获取系统当前的年、月、日、小时、分钟、毫秒
    let date = new Date()
    let year = date.getFullYear()
    let month = date.getMonth() + 1
    let day = date.getDate()
    let hour = date.getHours()
    let minutes = date.getMinutes()
    let seconds = date.getSeconds()
    dates.value = `${year}年${month}月${day}日 ${check(hour)}:${check(minutes)}:${check(seconds)}`
}
//每隔1秒调用一次displayTime函数
const start = () => {
    setInterval(() => {
        displayTime()
    }, 1000) //单位是毫秒
}

const baseURL = axios.defaults.baseURL;
const tabvalue = ref(1)
const tabName = ref('')
const current = ref(1)
const total = ref(0)
const typeIds = ref([null, null, null, null, null, null, null, null, null])
const typeList = ref([
    {
        title: '领域',
        showMore: false,
        list: [
            {
                name: '综合',
                id: 1,
            },
            {
                name: '电子信息',
                id: 2,
            },
            {
                name: '文化创意',
                id: 3,
            },
            {
                name: '先进制造',
                id: 4,
            },
            {
                name: '生物医药与医疗器械',
                id: 5,
            },
            {
                name: '新能源与节能',
                id: 6,
            },
            {
                name: '电子商务',
                id: 7,
            },
        ],
    },
    {
        title: '面积',
        showMore: false,
        list: [
            {
                name: '1-1000m²',
                id: 1,
            },
            {
                name: '1000-3000m²',
                id: 2,
            },
            {
                name: '3000-5000m²',
                id: 3,
            },
            {
                name: '5000-8000m²',
                id: 4,
            },
            {
                name: '8000-10000m²',
                id: 5,
            },
            {
                name: '10000m²以上',
                id: 6,
            }
        ],
    },
])
const arearShowMore = ref(false)
const areaIndex = ref(0)
const dataList = ref([])
const pages = reactive({
    number: 1, //第几页
    size: 5, //每页中显示数据的条数
})
const field = reactive({
    type: '众创空间',
    fieldStr: '',
    name: '',
})
const areadata = ref([{ children: [] }])
function getArear() {
    getarea({}).then((res) => {
        if (res.code == 200) {
            areadata.value = res.data
            if (localStorage.getItem('orgInfo')) {
                areaIndex.value = JSON.parse(localStorage.getItem('orgInfo')).areaIndex == -1 ? 0 : JSON.parse(localStorage.getItem('orgInfo')).areaIndex
            }
            console.log('111');
            getListData()
        }
    })
}
const headerKey = ref(0)
function getOrg() {
    var orgInfo = {}
    if (areaIndex.value == -1) {
        orgInfo = {}
    } else if (areaIndex.value == 0) {
        orgInfo = { orgId: areadata.value[0].id, areaIndex: areaIndex.value, areaName: '' }
    } else {
        orgInfo = { orgId: areadata.value[0].children[areaIndex.value].id, areaIndex: areaIndex.value, areaName: '' }
    }
    localStorage.setItem('orgInfo', JSON.stringify(orgInfo))
    getListData()
    headerKey.value++
}
function setType(index, item) {
    // console.log(index);
    // console.log(item.name);
    pages.number = 1
    pages.size = 5
    if (index == 0) {
        if (item) {
            field.fieldStr = item.name || ''
        } else {
            field.fieldStr = ''
        }
    }
    if (index == 1) {
        if (item) {
            if (item.name.includes("以上")) {
                field.acreage = item.name.split('m²以上')[0] ? item.name.split('m²以上')[0] : ''
            }
            else {
                field.acreage = item.name.split('-')[0] ? item.name.split('-')[0] : ''
            }
            field.acreageMax = item.name.split('-')[1] ? item.name.split('-')[1].split('m²')[0] : ''
        } else {
            field.acreage = ''
            field.acreageMax = ''
        }
    }
    if (index == 2) {
        if (item) {
            field.city = item.name || ''
        } else {
            field.city = ''
        }
    }
    typeIds.value[index] = item ? item.id : null
    getListData()
}
const gotoPath = (path, data) => {
    router.push({ path: path, query: data })
}

async function getData() {
    industryOne().then((response) => {
        console.log(response)
        if (response.code == 200) {
            typeList.value[0].list = response.data
        } else {
        }
    })
}
async function getListData() {
    var datas = { ...field, ...pages }
    if (areaIndex.value == -1) {
        datas.orgFlag = '0'
    }
    let params = JSON.parse(JSON.stringify(datas))
    params.orgId = areadata.value[0].children[areaIndex.value].id
    innovationList(params).then((response) => {
        console.log(response)
        if (response.code == 200) {
            dataList.value = response.data.list
            total.value = response.data.total
            console.log(response.data.total)
        } else {
        }
    })
}
async function pageChange(current, pageSize) {
    pages.number = current
    pages.size = pageSize
    getListData()
}

const toDetail = (id) => {
    router.push({
        path: '/bigScreen/spaceDetail',
        query: {
            id
        }
    })
}

const goBack = () => {
    router.push('/chart')
}

onMounted(() => {
    start()
    getData()
    getArear()
    // getListData()
})
</script>

<style scoped lang="scss">
::v-deep {
    .ant-btn-primary {
        border-color: #037aff;
        background: #037aff;
    }

    .ant-input {
        background: rgba(68, 148, 255, 0.12);
        border: none;
        color: #ffffff;
    }

    .ant-pagination-item {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0b2f5f;
    }

    .ant-pagination-item a {
        color: #ffffff;
    }

    .ant-pagination-prev .ant-pagination-item-link,
    .ant-pagination-next .ant-pagination-item-link {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0b2f5f;
        color: #707981;
    }

    .ant-pagination-disabled .ant-pagination-item-link {
        background: rgba(8, 26, 48, 0.8);
        border: 1px solid #0b2f5f;
        color: #707981;
    }

    .ant-pagination-item-active {
        background: #004dfd;
        border-radius: 2px;
        border: none;
    }

    .ant-pagination-jump-prev
        .ant-pagination-item-container
        .ant-pagination-item-ellipsis,
    .ant-pagination-jump-next
        .ant-pagination-item-container
        .ant-pagination-item-ellipsis {
        color: #ffffff;
    }
}
@font-face {
    font-family: "ffa";
    src: url(../../../assets/bigScreen/fonts/DS-DIGIB.TTF);
}
ul,
li {
    list-style: none;
}
.big-box {
    background-color: #071c3b;
    height: 100vh;
}
.header {
    position: relative;
    text-align: center;
    position: relative;
    height: 19.1rem;

    .backBox {
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 70rem;
        height: 10rem;
        cursor: pointer;
    }

    > img {
        width: 100%;
        max-height: 100%;
        margin-top: -1.1rem;
        image-rendering: -moz-crisp-edges; /* Firefox */
        image-rendering: -o-crisp-edges; /* Opera */
        image-rendering: -webkit-optimize-contrast; /* Webkit (non-standard naming) */
        image-rendering: crisp-edges;
        -ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */
    }
}
.centerBox {
    width: 96%;
    margin: 0 auto;
    position: absolute;
    top: 14rem;
    left: 2%;
    .sreenTitle {
        background-image: url("../../../../../assets/bigScreen/sreenTitle.png");
        background-size: 100% 100%;
        height: 3.8rem;
        padding-left: 35px;
        font-weight: 600;
        color: #fff;
        display: flex;
        align-items: center;
    }
    .center {
        margin-top: 1rem;
        height: calc(100vh - 20rem);
        border: 1px solid;
        border-image: linear-gradient(
                130deg,
                #2385df 0%,
                rgba(35, 133, 223, 0.65) 92%
            )
            1;
        overflow-y: scroll;
        padding: 20px;
    }
    ::-webkit-scrollbar {
        width: 5px;
        height: 10px;
    }

    /* 滚动条轨道 */
    ::-webkit-scrollbar-track {
        background-color: #234470;
    }

    /* 滚动条滑块 */
    ::-webkit-scrollbar-thumb {
        background-color: #061c57;
    }

    /* 鼠标悬停在滚动条上的滑块 */
    ::-webkit-scrollbar-thumb:hover {
        background-color: #555;
    }
}
.backToBox {
    position: absolute;
    top: 8rem;
    right: 2%;
    display: flex;
    .backTo {
        background-image: url("../../../../../assets/bigScreen/backTo.png");
        color: #2dccff;
        background-size: 100% 100%;
        width: fit-content;
        padding: 2px 40px 10px 10px;
        font-weight: 600;
        cursor: pointer;
        margin-left: 10px;
        div {
            padding-top: 5px;
        }
    }
}

.incubation_search {
    .headerImg {
        background-size: 100% 100%;
        width: 100%;
        height: 38rem;
        color: #fff;
        background-image: url("../../../assets/headerImg/incubation.png");

        .hearder_top {
            height: 29rem;
            display: flex;
            justify-content: space-between;
            align-items: center;

            .searchBox {
                width: 72.5rem;

                ::v-deep(.ant-input-group-wrapper) {
                    border-radius: 1000rem;
                    overflow: hidden;
                    font-size: 12px;
                }

                ::v-deep(.ant-input-group-addon) {
                    left: 0;
                }

                ::v-deep(.ant-btn-lg) {
                    padding-left: 5rem;
                    padding-right: 5rem;
                    font-size: 12px;
                    line-height: 1.5;
                }

                ::v-deep(.ant-input-lg) {
                    font-size: 14px;
                    line-height: 1.8;
                }
            }
        }

        .tabBox {
            background: rgba(0, 0, 0, 0.52);
            height: 9rem;
            width: 100%;

            .tabItemActive {
                width: 28rem;
                height: 9rem;
                display: flex;
                justify-content: center;
                align-items: center;
                cursor: pointer;
                background-color: #037aff;
            }

            .tabItem {
                width: 28rem;
                height: 9rem;
                display: flex;
                justify-content: center;
                align-items: center;
                cursor: pointer;
            }

            .tabItem:hover {
                color: #037aff;
            }
        }

        .title {
            font-size: 5rem;
            font-weight: 600;
            // text-align: center;
            font-style: italic;
            letter-spacing: 0.1rem;
            // color: #ffffff;
        }

        .subtitle {
            font-size: 1.5rem;
            font-weight: 600;
            text-align: center;
            letter-spacing: 0.1rem;
        }
    }

    .searchListBox {
        margin-top: 2rem;

        .sitem {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 3.7rem 0;
            border-bottom: #4494ff46 1px solid;

            .sleft {
                display: flex;
                align-items: center;

                img {
                    width: 18rem;
                    height: 18rem;
                }

                .textBox {
                    margin-left: 2rem;

                    .title {
                        font-size: 2.6rem;
                        line-height: 6rem;
                        color: #ffffff;
                    }

                    .type {
                        border: 1px solid #037aff;
                        border-radius: 4px;
                        padding: 0 1rem;
                        font-size: 12px;
                        margin-left: 2rem;
                        color: #037aff;
                    }

                    .subtext {
                        font-size: 1.6rem;
                        font-weight: normal;
                        line-height: 4.4rem;
                        letter-spacing: 0em;
                        color: #ffffff;
                    }
                }
            }

            .sright {
                border: 1px solid #037aff;
                border-radius: 4px;
                padding: 1rem 3rem;
                font-size: 12px;
                color: #037aff;
            }

            .sright:hover {
                border: 1px solid #037aff;
                border-radius: 4px;
                padding: 1rem 3rem;
                font-size: 12px;
                background-color: #037aff;
                color: #ffffff;
                cursor: pointer;
            }
        }
    }

    .filter-container {
        width: 100%;
        padding-top: 20px;
        // background: #f6faff;
        padding: 3rem;
        margin-top: 4.8rem;

        .filter-type {
            height: 55px;
            position: relative;
            padding-right: 90px;
            overflow: hidden;
            display: flex;
            flex-wrap: wrap;
            justify-content: left;

            .filter-type-title {
                display: inline-block;
                // width: 8rem;
                margin-right: 40px;
                font-size: 15px;
                color: #ffffff;
                white-space: nowrap;
            }

            .filter-item {
                display: inline-block;
                margin-bottom: 30px;
                padding: 0 15px;
                height: 25px;
                line-height: 25px;
                border-radius: 4px;
                font-size: 15px;
                color: #ffffff;
                cursor: pointer;
            }

            .filter-item.active {
                background-color: #037aff;
                color: #fff;
            }

            .filter-more-btn {
                position: absolute;
                right: 0;
                top: 0;
                cursor: pointer;
                display: flex;
                align-items: center;
            }

            .filter-more-btn span {
                font-size: 16px;
                color: #037aff;
            }

            .filter-more-btn img {
                width: 10px;
                height: 5px;
                margin-left: 8px;
                margin-top: 8px;
            }
        }
    }
}

.typeContent {
    width: 140rem;
    margin: 0 auto;
    position: relative;
    // padding: 0rem 0 5rem 0;
}
</style>
